<?php
/*
 * 会员控制器
 */
class sysmemberCtrl extends lib_ctrl{
	
	public $member;
	
	public function _init(){
		$this->member = loadModel('member');
	}
	
  /*
    #删除会员
    */
    function delAct()
    {
        if(!empty($_POST)){
	        $id = abs(intval($_POST['id']));
	        if(!$id)exit('-11');

            $res = $this->member->delMember($id);
            if($res) exit('1');
            exit($res);
        }
        exit('-10');
    }
        /*
     * 会员充值
     */
    function chargeAct( )
    {
        $mid = intval($_GET['id']);
        if(!empty($_POST)){
            $member_id = $_POST['member_id'];
            $member_money = isset($_POST['member_money']) ? floatval($_POST['member_money']) : 0;
            $member_point = isset($_POST['member_point']) ? intval($_POST['member_point']) : 0;
            $member_notes = isset($_POST['member_notes']) ? strip_tags($_POST['member_notes']) : '';
            $member = $this->member->setID(12)
                ->setLimit(1)
                ->select( );
            if($member){
                if($member_money) $info['money'] = $member['money'] + $member_money;
                if($member_point) $info['point'] = $member['point'] + $member_point;
                $res = $this->member->setID($member_id)->update($info);
                if($res) exit('1');
                exit($res);
            }else{
                exit('-1'); #会员ID不是有效的
            }
        }
        if($mid) $this->view->assign('mid', $mid);
        $this->view->display('sysmkt/member_charge.html');
    }
    
    
}